from django.db import models

# Create your models here.


# 用户表
class User(models.Model):
    # 用户名
    username = models.CharField(max_length=20)
    # 密码
    password = models.CharField(max_length=120)
    # 邮箱
    email = models.CharField(max_length=20)
    # 会员id  默认为1
    level = models.IntegerField(default=1)
    # 职业
    job = models.CharField(max_length=20)
    # 头像
    img = models.CharField(max_length=120)
    # 邀请码
    code = models.CharField(max_length=20)
    # 注册时间
    register_time = models.DateField(auto_now_add=True)
    # 积分
    score = models.IntegerField(default=0)
    # 开通会员时间  str
    vip_start_time = models.CharField(max_length=30)
    # 会员到期时间  str
    vip_end_time = models.CharField(max_length=30)
    # 是否管理员  0非管理员  1管理员
    is_admin = models.IntegerField(default=0)
    # 是否老师  0非老师  1老师
    is_teacher = models.IntegerField(default=0)

    class Meta:
        db_table = 'user'


# 三方登录表
class PartiesLogin(models.Model):
    # 第三方username或user_id
    username = models.CharField(max_length=30)
    # 用户id（和用户表的对应用户绑定）
    uid = models.IntegerField()
    # 三方登录平台（微博，钉钉）
    type = models.CharField(max_length=10)

    class Meta:
        db_table = 'partieslogin'


# 会员表
class Vip(models.Model):
    # 会员类型
    level = models.CharField(max_length=10)
    # 用户id
    uid = models.IntegerField()

    class Meta:
        db_table = 'vip'


# 用户——课程关系表
class User_To_Course(models.Model):
    # 用户id
    user = models.IntegerField()
    # 课程id
    course = models.IntegerField()

    class Meta:
        db_table = 'user_to_course'


# 课程表
class Course(models.Model):
    # 课程标题
    title = models.CharField(max_length=30)
    # 上传教师
    author = models.IntegerField(default=0)
    # 封面
    img = models.CharField(max_length=120)
    # 课程类型（免费，会员，限免）存放课程类型id
    astrict_id = models.IntegerField(default=0)
    # 关注数
    flow = models.IntegerField(default=0)
    # 学习人数
    learning_num = models.IntegerField(default=0)
    # 简介
    brief = models.CharField(max_length=50)
    # 是否上线  0不上线  1上线
    is_online = models.IntegerField(default=0)
    # 价格
    price = models.IntegerField()

    class Meta:
        db_table = 'course'


# 课程类型表
class Astrict(models.Model):
    # 课程类型（免费，会员，高级会员，限免）
    type = models.CharField(max_length=10)

    class Meta:
        db_table = 'astrict'


# 课程标签表
class CourseTags(models.Model):
    # 标签名称
    tag_title = models.CharField(max_length=20)

    class Meta:
        db_table = 'coursetags'


# 课程——标签关系表
class Course_To_Tags(models.Model):
    # 课程id
    course = models.IntegerField()
    # 标签id
    tag = models.IntegerField()

    class Meta:
        db_table = 'course_to_tags'


# 章节表
class Chapter(models.Model):
    # 章节名
    chapter = models.CharField(max_length=30)
    # 视频
    video = models.CharField(max_length=50)
    # 课程id
    course = models.IntegerField()

    class Meta:
        db_table = 'chapter'
